/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.seguradora.util;

import com.towel.bean.Formatter;
import java.text.NumberFormat;
import java.text.ParseException;

/**
 *
 * @author Diego
 */
public class MoneyFormatter implements Formatter {

    NumberFormat nf = NumberFormat.getCurrencyInstance();

    @Override
    public String format(Object arg0) {
        return nf.format(arg0);
    }

    @Override
    public String getName() {
        return "money";
    }

    @Override
    public Object parse(Object arg0) {
        Double value = null;
        try {
            value = nf.parse(arg0.toString()).doubleValue();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return value;
    }
}
